Skip to content

src: add fast api call to push span strings#283

Closed
santigimeno wants to merge 2 commits intonode-v22.x-nsolid-v5.xfrom
santi/fast_push_string
Closed

src: add fast api call to push span strings#283
santigimeno wants to merge 2 commits intonode-v22.x-nsolid-v5.xfrom
santi/fast_push_string

Conversation

@santigimeno
Copy link
Copy Markdown
Member

No description provided.

@santigimeno santigimeno self-assigned this Mar 28, 2025
This commit introduces performance optimizations for tracing span
attribute handling by adding two new fast API calls:

1. FastPushSpanDataString - Optimized version of the existing string push method
2. FastPushSpanDataString3 - New method to efficiently handle three string
   values in a single call

Key changes include:
- Avoided JavaScript string concatenation which produces non-flattened V8
  strings that cannot trigger fast API paths
- Implemented direct passing of individual string components to C++ where
  concatenation can happen after the fast API boundary
- Refactored HTTP URL construction in both client and server to leverage
  this optimization
- Improved span context handling by storing trace ID, span ID, and parent
  span ID as separate attributes rather than a single concatenated string

These optimizations significantly improve performance in high load scenarios:
- Up to 3.24% higher throughput in maximum load tests
- Up to 57.75% lower latency at P99.9 under constant high rate (50k req/sec)
- Substantial improvements across all high percentile latencies (P95-P99.999)
- Most dramatic gains observed in tail latencies under sustained heavy load

=== Benchmark Summary ===

Benchmark Type: wrk2 (constant rate)
Old Version: ./nsolid_baseline
New Version: ./nsolid_fast_push_string
Iterations: 50
Connections: 10
Duration: 60s
Rate: 40k req/sec

+------------------+-------------+-------------+------------+-----+
| Metric           | Old Version | New Version | Difference | Sig |
+------------------+-------------+-------------+------------+-----+
| Avg Latency (ms) | 2.58        | 2.34        | N/A        |     |
| P50 Latency (ms) | 1.09        | 1.10        | +0.80%     | *** |
| P90 Latency (ms) | 2.22        | 2.20        | -0.63%     | *** |
| P99 Latency (ms) | 3.09        | 2.99        | -3.31%     | *** |
| Avg Req/Sec      | 39,992.50   | 39,992.53   | +0.00%     |     |
+------------------+-------------+-------------+------------+-----+

=== Benchmark Summary ===

Benchmark Type: wrk2 (constant rate)
Old Version: ./nsolid_baseline
New Version: ./nsolid_fast_push_string
Iterations: 50
Connections: 10
Duration: 60s
Rate: 50k req/sec

+------------------+-------------+-------------+------------+-----+
| Metric           | Old Version | New Version | Difference | Sig |
+------------------+-------------+-------------+------------+-----+
| Avg Latency (ms) | 9.92        | 5.20        | N/A        |     |
| P50 Latency (ms) | 0.95        | 0.94        | -0.54%     |     |
| P90 Latency (ms) | 2.54        | 2.35        | -7.47%     | *** |
| P99 Latency (ms) | 12.00       | 5.58        | -53.49%    | *** |
| Avg Req/Sec      | 49,990.78   | 49,990.72   | -0.00%     |     |
+------------------+-------------+-------------+------------+-----+

=== Benchmark Summary ===

Benchmark Type: wrk (maximum throughput)
Old Version: ./nsolid_baseline
New Version: ./nsolid_fast_push_string
Iterations: 50
Connections: 10
Duration: 60s
Threads: 2

+------------------+-------------+-------------+------------+-----+
| Metric           | Old Version | New Version | Difference | Sig |
+------------------+-------------+-------------+------------+-----+
| Avg Latency (ms) | 0.65        | 0.64        | N/A        |     |
| P50 Latency (ms) | 0.17        | 0.16        | -3.48%     | *** |
| P90 Latency (ms) | 0.33        | 0.32        | -2.30%     | *** |
| P99 Latency (ms) | 0.36        | 0.35        | -3.33%     | *** |
| Avg Req/Sec      | 52,398.20   | 54,094.55   | +3.24%     | *** |
+------------------+-------------+-------------+------------+-----+
@santigimeno santigimeno force-pushed the santi/fast_push_string branch from cef497d to 17c1fe8 Compare April 8, 2025 18:25
@santigimeno santigimeno closed this Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants